package cn.huiyunche.driver.controller;

import cn.huiyunche.base.service.interfaces.OtmMonitoringService;
import cn.huiyunche.base.service.vo.MonitoringOrderVo;
import cn.huiyunche.base.service.vo.PageVo;
import cn.huiyunche.base.service.vo.Result;
import cn.huiyunche.tools.basic.exceptions.BusinessException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * otm订单监控
 *
 */
@Controller
@RequestMapping("/monitoring")
public class OtmMonitoringController {

    private static final Logger LOGGER = LoggerFactory.getLogger(OtmMonitoringController.class);

    @Autowired
    OtmMonitoringService otmMonitoringService;
    /**
     * 监控派单
     * @return
     */
    @RequestMapping(value = "/order", method = RequestMethod.POST)
    @ResponseBody
    public Result<Map<String,Object>> monitoringOrder(PageVo pageVo, String shipmentId, String beginDate, String endDate) throws Exception {
        LOGGER.info(" monitoringOrder params : {}.", pageVo);
        Result<Map<String,Object>> result = new Result<>(true, "查询成功");
        try {
            result.setData(otmMonitoringService.monitoringOrder(pageVo, shipmentId, beginDate, endDate));
        } catch (BusinessException e) {
            LOGGER.error("monitoringOrder error : {}",e);
            result.setSuccess(false);
            result.setMessage(e.getMessage());
        } catch (Exception e) {
            LOGGER.error("monitoringOrder error : {}",e);
            result.setSuccess(false);
            result.setMessage("查询失败");
        }
        return result;
    }

}
